---
title: "Reputation penalty - study 3, survey 1"
author: "Jacob Ausubel, Annika Davies, and Ethan Porter"
date: "2025-08-28"
output:
  pdf_document:
    extra_dependencies: float
  word_document: default
  html_document:
    df_print: paged
fontsize: 12pt
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# Study 3, survey 1

Note that we used this survey to decide which activists (i.e., Seth Gruber and Ben Shapiro) we were using for Study 3.

```{r, include = FALSE, message = FALSE}
#Clear global environment
rm(list = ls())
```

```{r, include = FALSE, message = FALSE}
#Loading various packages
library(readr)
library(lmtest)
library(sandwich)
library(margins)
library(texreg)
library(haven)
library(MASS)
library(dplyr)
library(ggplot2)
library(ggrepel)
library(marginaleffects)
library(estimatr)
library(imputeTS)
library(fabricatr)
library(tidyr)
library(tidyverse)
library(lubridate)
library(qualtRics)
library(naniar)
library(RCT)
library(texreg)
library(huxtable)
library(stargazer)
library(ggpubr)
library(vtable)
library(cobalt)
library(kableExtra)
library(xtable)
library(ggthemes)
library(stats)
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Read in data
#recog_penalty_private <- read_csv("Recognizability Penalty_July 11, 2024_14.01.csv")
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Creating public version of dataset that doesn't include personally identifying information
#recog_penalty_public <-
#  recog_penalty_private %>%
#  filter(Status == "IP Address") %>%
#  select(-c(Status, IPAddress, ResponseId, RecipientLastName, RecipientFirstName, 
#            RecipientEmail, ExternalReference, LocationLatitude, LocationLongitude, 
#            DistributionChannel, state, assignmentId, participantId, projectId))
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Creating public CSV file
#write.csv(recog_penalty_public, "Recognizability Penalty_July 11, 2024_14.01 - PUBLIC.csv", row.names = FALSE)
```

```{r, include = FALSE, message = FALSE}
#Reading in data
recog_penalty <- read_csv("Recognizability Penalty_July 11, 2024_14.01 - PUBLIC.csv")
```


```{r, message = FALSE, warning = FALSE, include = FALSE}
#Filtering to just respondents who passed the attention checks
recog_penalty_v2 <-
  recog_penalty %>%
  filter(!ac1 %in% c("Climbed Mt. Everest", 
                     "Starred in a movie", 
                     "Starred in a movie,Talked on the telephone",
                     "Watched television,Climbed Mt. Everest", 
                     "Watched television,Climbed Mt. Everest,Starred in a movie,Talked on the telephone",
                     "Watched television,Starred in a movie",
                     "Watched television,Starred in a movie,Talked on the telephone")) %>%
  filter(`attention check` == "Extremely interested,Very interested")
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Getting rid of white space in column names
colnames(recog_penalty_v2) <-
  trimws(colnames(recog_penalty_v2))
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Recoding familiarity variable for Franklin Graham III
recog_penalty_v2$graham_familiar_v2 <- recog_penalty_v2$`graham_familiar `

recog_penalty_v2$graham_familiar_v2 <-
  factor(recog_penalty_v2$graham_familiar_v2,
  levels = c("Extremely unfamiliar", "Unfamiliar",
             "Somewhat unfamiliar", "Somewhat familiar",
             "Familiar", "Extremely familiar"))

recog_penalty_v2$graham_familiar_v3 <- 
  as.numeric(recog_penalty_v2$graham_familiar_v2)

recog_penalty_v2$graham_familiar_v4 <- 
  ifelse(recog_penalty_v2$graham_familiar_v3 %in% c(4,5,6), 1, 0)
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Recoding familiarity variable for Seth Gruber
recog_penalty_v2$gruber_familiar_v2 <- recog_penalty_v2$gruber_familiar

recog_penalty_v2$gruber_familiar_v2 <-
  factor(recog_penalty_v2$gruber_familiar_v2,
  levels = c("Extremely unfamiliar", "Unfamiliar",
             "Somewhat unfamiliar", "Somewhat familiar",
             "Familiar", "Extremely familiar"))

recog_penalty_v2$gruber_familiar_v3 <- 
  as.numeric(recog_penalty_v2$gruber_familiar_v2)

recog_penalty_v2$gruber_familiar_v4 <- 
  ifelse(recog_penalty_v2$gruber_familiar_v3 %in% c(4,5,6), 1, 0)
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Recoding familiarity variable for Charlie Kirk
recog_penalty_v2$kirk_familiar_v2 <- recog_penalty_v2$kirk_familiar

recog_penalty_v2$kirk_familiar_v2 <-
  factor(recog_penalty_v2$kirk_familiar_v2,
  levels = c("Extremely unfamiliar", "Unfamiliar",
             "Somewhat unfamiliar", "Somewhat familiar",
             "Familiar", "Extremely familiar"))

recog_penalty_v2$kirk_familiar_v3 <- 
  as.numeric(recog_penalty_v2$kirk_familiar_v2)

recog_penalty_v2$kirk_familiar_v4 <- 
  ifelse(recog_penalty_v2$kirk_familiar_v3 %in% c(4,5,6), 1, 0)
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Recoding familiarity variable for Ben Shapiro
recog_penalty_v2$shapiro_familiar_v2 <- recog_penalty_v2$shapiro_familiar

recog_penalty_v2$shapiro_familiar_v2 <-
  factor(recog_penalty_v2$shapiro_familiar_v2,
  levels = c("Extremely unfamiliar", "Unfamiliar",
             "Somewhat unfamiliar", "Somewhat familiar",
             "Familiar", "Extremely familiar"))

recog_penalty_v2$shapiro_familiar_v3 <- 
  as.numeric(recog_penalty_v2$shapiro_familiar_v2)

recog_penalty_v2$shapiro_familiar_v4 <- 
  ifelse(recog_penalty_v2$shapiro_familiar_v3 %in% c(4,5,6), 1, 0)
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Recoding familiarity variable for James Dobson
recog_penalty_v2$dobson_familiar_v2 <- recog_penalty_v2$dobson_familiar

recog_penalty_v2$dobson_familiar_v2 <-
  factor(recog_penalty_v2$dobson_familiar_v2,
  levels = c("Extremely unfamiliar", "Unfamiliar",
             "Somewhat unfamiliar", "Somewhat familiar",
             "Familiar", "Extremely familiar"))

recog_penalty_v2$dobson_familiar_v3 <- 
  as.numeric(recog_penalty_v2$dobson_familiar_v2)

recog_penalty_v2$dobson_familiar_v4 <- 
  ifelse(recog_penalty_v2$dobson_familiar_v3 %in% c(4,5,6), 1, 0)
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Recoding familiarity variable for Tony Perkins
recog_penalty_v2$perkins_familiar_v2 <- recog_penalty_v2$perkins_familiar

recog_penalty_v2$perkins_familiar_v2 <-
  factor(recog_penalty_v2$perkins_familiar_v2,
  levels = c("Extremely unfamiliar", "Unfamiliar",
             "Somewhat unfamiliar", "Somewhat familiar",
             "Familiar", "Extremely familiar"))

recog_penalty_v2$perkins_familiar_v3 <- 
  as.numeric(recog_penalty_v2$perkins_familiar_v2)

recog_penalty_v2$perkins_familiar_v4 <- 
  ifelse(recog_penalty_v2$perkins_familiar_v3 %in% c(4,5,6), 1, 0)
```


```{r, message = FALSE, warning = FALSE, include = FALSE}
#Creating blank data frame (that I'll then fill in)
df <- data.frame(
  estimate = rep(NA, 6),  
  lower_ci = rep(NA, 6),  
  upper_ci = rep(NA, 6) 
)
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Assigning row names
rownames(df) <-
  c("Franklin Graham III", "Seth Gruber", "Charlie Kirk",
    "Ben Shapiro", "James Dobson", "Tony Perkins")
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Creating activist name column
df$name <- rownames(df)
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Filling in data frame with how familiar respondents are with the activists
  #(as well as 95% confidence intervals)
df[1,1] <-
  as.numeric(t.test(recog_penalty_v2$graham_familiar_v4)$estimate)
df[1,2] <-
  t.test(recog_penalty_v2$graham_familiar_v4)$conf.int[1]
df[1,3] <-
  t.test(recog_penalty_v2$graham_familiar_v4)$conf.int[2]

df[2,1] <-
  as.numeric(t.test(recog_penalty_v2$gruber_familiar_v4)$estimate)
df[2,2] <-
  t.test(recog_penalty_v2$gruber_familiar_v4)$conf.int[1]
df[2,3] <-
  t.test(recog_penalty_v2$gruber_familiar_v4)$conf.int[2]

df[3,1] <-
  as.numeric(t.test(recog_penalty_v2$kirk_familiar_v4)$estimate)
df[3,2] <-
  t.test(recog_penalty_v2$kirk_familiar_v4)$conf.int[1]
df[3,3] <-
  t.test(recog_penalty_v2$kirk_familiar_v4)$conf.int[2]

df[4,1] <-
  as.numeric(t.test(recog_penalty_v2$shapiro_familiar_v4)$estimate)
df[4,2] <-
  t.test(recog_penalty_v2$shapiro_familiar_v4)$conf.int[1]
df[4,3] <-
  t.test(recog_penalty_v2$shapiro_familiar_v4)$conf.int[2]

df[5,1] <-
  as.numeric(t.test(recog_penalty_v2$dobson_familiar_v4)$estimate)
df[5,2] <-
  t.test(recog_penalty_v2$dobson_familiar_v4)$conf.int[1]
df[5,3] <-
  t.test(recog_penalty_v2$dobson_familiar_v4)$conf.int[2]

df[6,1] <-
  as.numeric(t.test(recog_penalty_v2$perkins_familiar_v4)$estimate)
df[6,2] <-
  t.test(recog_penalty_v2$perkins_familiar_v4)$conf.int[1]
df[6,3] <-
  t.test(recog_penalty_v2$perkins_familiar_v4)$conf.int[2]
```

```{r, message = FALSE, warning = FALSE, include = FALSE}
#Rearranging it so that the activists are in order of how familiar people are with them
df <-
  df %>%
  arrange(-estimate)
```

```{r, echo = FALSE}
#Creating graph of how familiar people are with the activists
ggplot(df) +
  geom_bar(aes(x=reorder(name,-estimate), y=estimate), stat="identity", fill="skyblue", alpha=0.7) +
  geom_errorbar(aes(x=name, ymin=lower_ci, ymax=upper_ci), width=0.4, colour="orange", alpha=0.9) +
  theme_classic() +
  xlab("Political activist") +
  ylab("Share who recognize name (%)")
```
